package com.cafe.service.impl;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cafe.dao.NoticeDao;
import com.cafe.model.Notice;
import com.cafe.service.NoticeService;
import com.malamute.core.common.Page;

/**
 * @description 公告业务接口实现
 * @version v1.0
 */
@Service
public class NoticeServiceImpl implements NoticeService {
	@Autowired
	private NoticeDao noticeDao;

	/*
	 * (non-Javadoc)
	 * 
	 * @param notice
	 * 
	 * @see com.cafe.service.NoticeService#saveNotice(com.cafe.model.Notice)
	 */
	@Override
	public void saveNotice(Notice notice) {
		noticeDao.save(notice);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @param notice
	 * 
	 * @see com.cafe.service.NoticeService#updateNotice(com.cafe.model.Notice)
	 */
	@Override
	public void updateNotice(Notice notice) {
		noticeDao.update(notice);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @param id
	 * 
	 * @see com.cafe.service.NoticeService#deleteNoticeById(java.lang.Integer)
	 */
	@Override
	public void deleteNoticeById(Integer id) {
		noticeDao.deleteByKey(id);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @param id
	 * 
	 * @return
	 * 
	 * @see com.cafe.service.NoticeService#getNoticeById(java.lang.Integer)
	 */
	@Override
	public Notice getNoticeById(Integer id) {
		return noticeDao.get(id);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @param criteria
	 * 
	 * @param page
	 * 
	 * @see
	 * com.cafe.service.NoticeService#listNoticesByPage(org.hibernate.criterion
	 * .DetachedCriteria, com.malamute.core.common.Page)
	 */
	@Override
	public void listNoticesByPage(DetachedCriteria criteria, Page page) {
		noticeDao.listByPage(criteria, page);
	}

	@Override
	public List listAvailableNotice(DetachedCriteria criteria) {
		return noticeDao.findByCriteria(criteria);
	}

}
